#!/usr/bin/python

import WykopRespProfile
import SimpleRequest
import WykopRespLink
import WykopRespGroup

class WykopProfile(SimpleRequest.SimpleRequest):
    
    H_WykopAPI = None
    
    def _sng_query(self, type, login, Page = None, Id = None):

        self._addElement('profile')
        self._addElement(type, login)
        if Id!= None:
            self._addElement('id',str(Id))
        if Page !=None:
            self._addElement('page',str(Page))
        self._addAPIElement(self.H_WykopAPI._appkey, self.H_WykopAPI._userkey)
        self._send()
        return self._getData()
        
    def __init__(self, WykopAPIHandler):
        
        self.H_WykopAPI =  WykopAPIHandler
        
    def getIndex(self, Login):
        
        C = WykopRespProfile.WykopRespProfile()
        return C._normalizeData(self._sng_query('index',Login))
    
    def getAdded(self, Login, Page = None):
        
        C = WykopRespLink.WykopRespLink()
        return C._normalizeData(self._sng_query('added',Login,Page))
    
    def getGroups(self, Login, Page = None):
    
        C= WykopRespGroup.WykopRespGroup()
        return C._normalizeData(self._sng_query('groups',Login,Page))
    
    def getPublished(self, Login, Page = None):
        
        C = WykopRespLink.WykopRespLink()
        return C._normalizeData(self._sng_query('published',Login,Page))
    
    def getCommented(self, Login, Page = None):
        
        C = WykopRespLink.WykopRespLink()
        return C._normalizeData(self._sng_query('commented',Login,Page))
    
    def getDigged(self, Login, Page = None):
        
        C = WykopRespLink.WykopRespLink()
        return C._normalizeData(self._sng_query('digged',Login,Page))
    
    def getBuried(self, Login, Page = None):
        
        C = WykopRespLink.WykopRespLink()
        return C._normalizeData(self._sng_query('buried',Login,Page))
    
    def setObserve(self,Login):
        
        Data = self._sng_query('observe',Login)
        if 'error' in Data:
            return False
        else: 
            return True
            
    def setUnobserve(self,Login):
        
        Data = self._sng_query('unobserve',Login)
        if 'error' in Data:
            return False
        else: 
            return True
        
    def getFollowers(self, Login, Page = None):
        
        C = WykopRespProfile.WykopRespProfile()
        return C._normalizeDatatoList(self._sng_query('followers',Login,Page))
    
    def getFollowed(self, Login, Page = None):
        
        C = WykopRespProfile.WykopRespProfile()
        return C._normalizeDatatoList(self._sng_query('followed',Login,Page))
    
    def getFavorites(self, Login, Id,Page = None):
        
        C = WykopRespLink.WykopRespLink()
        return C._normalizeData(self._sng_query('favorites',Login,Page))
    
    
    
    